package com.mopa.qzonegallery;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class ImageAdapter extends BaseAdapter{
	private Context 				myctx;	
	public  List<ImageItemInfo> 	Allitems;
	
	public ImageAdapter(Context context) {
		super();
		myctx=context;
		Allitems=new ArrayList<ImageItemInfo>();
	}
	
	public void clear()
	    {
		   Allitems.clear();
		   notifyDataSetChanged();
	    }
	
   public void add(ImageItemInfo item)
    {
   	Allitems.add(item);
    }
   
   public void remove(ImageItemInfo item)
    {
   	  Allitems.remove(item);
    }

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
	  return Allitems.size();
	}

	@Override
	public ImageItemInfo getItem(int position) {
		// TODO Auto-generated method stub
		return Allitems.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ImageItemLayout curImageItem=(ImageItemLayout)convertView;
		if(curImageItem==null)
		{
			curImageItem=new ImageItemLayout(myctx);
		}
		curImageItem.initItem(getItem(position));
		return curImageItem;
	}

}
